package com.panda.admin.interfaces.param.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panda.admin.interfaces.param.service.SystemParamService;
import com.panda.admin.login.dto.ParamDto;
import com.panda.admin.login.entity.SystemParam;
import com.panda.admin.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * author: tcy
 * createDate: 2023/7/10
 * description: 参数配置控制
 */
@Api(tags = "参数配置")
@RestController
@RequestMapping("/param")
public class SystemParamController {

    @Autowired
    SystemParamService systemParamService;

    @ApiOperation(value = "条件分页查询")
    @PostMapping("/pageList")
    public Result<Page<SystemParam>> pageList(@RequestBody ParamDto paramDto){
        return Result.success(systemParamService.pageList(paramDto));
    }

    @ApiOperation(value = "查询参数详情")
    @GetMapping("/info/{id}")
    public Result<SystemParam> info(@PathVariable("id") Long id){
        return Result.success(systemParamService.info(id));
    }

    @ApiOperation(value = "增改参数")
    @PostMapping("/saveOrUpdateParam")
    public Result<Boolean> saveOrUpdateParam(@RequestBody SystemParam systemParam){
        return Result.success(systemParamService.saveOrUpdateParam(systemParam));
    }

    @ApiOperation(value = "删除参数")
    @PostMapping("/deleteParams")
    public Result<Boolean> deleteParams(@RequestBody List<Long> ids){
        return Result.success(systemParamService.deleteParams(ids));
    }

    @ApiOperation(value = "查询参数类型")
    @GetMapping("/queryTypes")
    public Result<List<SystemParam>> queryTypes(){
        return Result.success(systemParamService.queryTypes());
    }
}
